const mongoose = require('mongoose');
const Schema = mongoose.Schema;
const {saltRounds} = require('../configs/auth')

const bcrypt =require('bcrypt')

const UserSchema = new Schema({
	email: {
		type: String,
		unique: true,
		required: true
	},
	password: {
		type: String,
		set(val) {
			return bcrypt.hashSync(val, saltRounds)
		},
		required: true
	},
	name: {
		type: String,
		default: null
	},
	birthAt: {
		type: Date,
		default: null
	}
})

module.exports = mongoose.model('Users', UserSchema);